/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.educ.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

/**
 *
 * @author rpateixeira
 */
@Entity
@Table(name="MATERIAS")
public class Materia implements  Serializable{
    
    private Long id;
    private String nome;
    private List<Aluno> alunos;
    
    @Id
    @Column(name="SEQ_MATERIA")
    @TableGenerator(initialValue=150, allocationSize=10, name = "seq_materia", table="tb_sequences", valueColumnName="seq_count", pkColumnName="seq_name")
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "seq_materia")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    @Column(name="NOME_MATERIA")
    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }
    @ManyToMany(fetch=FetchType.EAGER)
    @JoinTable(
			name="ALUNO_MATERIA",
			joinColumns=@JoinColumn(name="ID_MATERIA",referencedColumnName="SEQ_MATERIA"),
			inverseJoinColumns=@JoinColumn(name="ID_ALUNO",referencedColumnName="SEQ_ALUNO")
    )
    public List<Aluno> getAlunos() {
        return alunos;
    }

    public void setAlunos(List<Aluno> alunos) {
        this.alunos = alunos;
    }
    
}
